package com.ruoyi.web.controller.fs;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.fs.domain.FsRepaymentStatistic;
import com.ruoyi.fs.service.IFsRepaymentStatisticService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 还款统计Controller
 * 
 * @author hero
 * @date 2024-11-11
 */
@RestController
@RequestMapping("/fs/statistic")
public class FsRepaymentStatisticController extends BaseController
{
    @Autowired
    private IFsRepaymentStatisticService fsRepaymentStatisticService;

    /**
     * 查询还款统计列表
     */
    @PreAuthorize("@ss.hasPermi('fs:statistic:list')")
    @GetMapping("/list")
    public TableDataInfo list(FsRepaymentStatistic fsRepaymentStatistic)
    {
        startPage();
        List<FsRepaymentStatistic> list = fsRepaymentStatisticService.selectFsRepaymentStatisticList(fsRepaymentStatistic);
        return getDataTable(list);
    }

    /**
     * 导出还款统计列表
     */
    @PreAuthorize("@ss.hasPermi('fs:statistic:export')")
    @Log(title = "还款统计", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FsRepaymentStatistic fsRepaymentStatistic)
    {
        List<FsRepaymentStatistic> list = fsRepaymentStatisticService.selectFsRepaymentStatisticList(fsRepaymentStatistic);
        ExcelUtil<FsRepaymentStatistic> util = new ExcelUtil<FsRepaymentStatistic>(FsRepaymentStatistic.class);
        util.exportExcel(response, list, "还款统计数据");
    }

    /**
     * 获取还款统计详细信息
     */
    @PreAuthorize("@ss.hasPermi('fs:statistic:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(fsRepaymentStatisticService.selectFsRepaymentStatisticById(id));
    }

    /**
     * 新增还款统计
     */
    @PreAuthorize("@ss.hasPermi('fs:statistic:add')")
    @Log(title = "还款统计", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FsRepaymentStatistic fsRepaymentStatistic)
    {
        return toAjax(fsRepaymentStatisticService.insertFsRepaymentStatistic(fsRepaymentStatistic));
    }

    /**
     * 修改还款统计
     */
    @PreAuthorize("@ss.hasPermi('fs:statistic:edit')")
    @Log(title = "还款统计", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FsRepaymentStatistic fsRepaymentStatistic)
    {
        return toAjax(fsRepaymentStatisticService.updateFsRepaymentStatistic(fsRepaymentStatistic));
    }

    /**
     * 删除还款统计
     */
    @PreAuthorize("@ss.hasPermi('fs:statistic:remove')")
    @Log(title = "还款统计", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(fsRepaymentStatisticService.deleteFsRepaymentStatisticByIds(ids));
    }
}
